
/**
 * 验证中间件
 */

export default function ({ app: { head }, store: { commit, $cookies }, route, redirect }) {

    commit('UPDATE_TITLE', head.title)

    const Vuex = $cookies.get('vuex');

    if (Vuex) {
        let TOKEN = Vuex.token;
        // 路由重定向
        if (TOKEN && route.name == 'login' || route.name == 'register') {

            return redirect('/')
        }

        if (!TOKEN && route.name == 'login-password') {

            return redirect('/')
        }
    }

}